package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.OtherBlocketRecord;
import com.ruoyi.system.domain.OtherRobotAdmin;
import com.ruoyi.system.mapper.OtherBlockedRecordMapper;
import com.ruoyi.system.mapper.OtherRobotAdminMapper;
import com.ruoyi.system.service.IOtherBlockedRecordService;
import com.ruoyi.system.service.IOtherRobotAdminService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
@DataSource(value = DataSourceType.SLAVE)
public class OtherBlockedRecordServiceImpl extends ServiceImpl<OtherBlockedRecordMapper, OtherBlocketRecord> implements IOtherBlockedRecordService {


    @Resource
    OtherBlockedRecordMapper otherBlockedRecordMapper;


    @DataSource(value = DataSourceType.SLAVE)
    public List<OtherBlocketRecord> getOtherBlockedRecord(String roomId) {
        return otherBlockedRecordMapper.selectList(new LambdaQueryWrapper<OtherBlocketRecord>()
                .eq(OtherBlocketRecord::getRoomID, roomId)
                .gt(OtherBlocketRecord::getEndTime, LocalDateTime.now()));
    }

    @DataSource(value = DataSourceType.SLAVE)
    public int deleteOtherBlockedRecord(Long id) {
       return otherBlockedRecordMapper.deleteById(id);
    }

}
